using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using HadronData;

namespace Hadron
{
    class PlayerProjectile
        : Projectile
    {
        private static Vector2 s_vecOrigin = new Vector2(16, 8);
        private static Rectangle s_rectangle = new Rectangle(0, 0, 32, 16);

        private Edge m_edgeGeometry;

        public PlayerProjectile(Environment p_environment)
            : base(p_environment)
        {
            m_edgeGeometry = new Edge();
            m_circleBounds.Radius = 32.0f;
        }

        public override Geometry Geometry
        {
            get { return m_edgeGeometry; }
        }

        public override void Update(GameTime p_gameTime)
        {
            base.Update(p_gameTime);

            Vector2 vecDelta = new Vector2((float)Math.Cos(m_fAngle) * 32.0f, (float)Math.Sin(m_fAngle) * 32.0f);

            m_edgeGeometry.Start = m_vecPosition - vecDelta;
            m_edgeGeometry.End = m_vecPosition; 
        }

        public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch p_spriteBatch)
        {
            Texture2D texturePlayerProjectile = AssetManager.Textures.PlayerProjectile;
            s_rectangle.X = (int)m_vecPosition.X;
            s_rectangle.Y = (int)m_vecPosition.Y;
            p_spriteBatch.Draw(texturePlayerProjectile, s_rectangle, null,
                Color.White, m_fAngle, s_vecOrigin, SpriteEffects.None, 0.0f);
        }
    }
}
